package com.xunkids.bos.migration.app.configuration;


import com.xunkids.bos.migration.component.transmission.api.MessagePool;
import com.xunkids.bos.migration.component.transmission.api.QueuePublisher;
import com.xunkids.bos.migration.component.transmission.api.QueueSubscriber;
import com.xunkids.bos.migration.component.transmission.api.TransportApi;
import com.xunkids.bos.migration.component.transmission.api.impl.CommonTransportService;
import com.xunkids.bos.migration.component.transmission.pojo.ResponseMessage;
import com.xunkids.bos.migration.component.transmission.pojo.TransportMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Map;

/**
 * common transition configuration
 *
 * @author xigexb
 * @version 1.0.0
 * @since 2022/11/4 10:53
 */
@Configuration
public class CommonTransmissionConfiguration {

    private static final Logger logger = LoggerFactory.getLogger(CommonTransmissionConfiguration.class);


    @ConditionalOnMissingBean(value = {TransportApi.class})
    @Bean("transportApi")
    public TransportApi transportApi(QueuePublisher queuePublisher,
                                     QueueSubscriber queueSubscriber
                                    ) {
        CommonTransportService service = new CommonTransportService( queuePublisher, queueSubscriber);
        if (logger.isInfoEnabled()) {
            logger.info("init common transportApi success");
        }
        return service;
    }
}
